import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home'
import About from '../views/About'
import News from '../views/Home/News'
import Message from '../views/Home/Message'
import Detail from '../views/Home/Message/Detail'
Vue.use(Router)

const router = new Router({
  mode:'history',
  routes: [
    {
      path: '/home',
      component: Home,
      children: [
        {
          path: 'news',
          component: News,
        },
        {
          path: 'message',
          component: Message,
          children: [
            {
              name: 'Detail',
              path: 'detail/:id',
              component: Detail,
              props($route){
                return{
                  ...$route.params,
                  ...$route.query,
                }
              }
            },
          ],
        },
        {
          path: '',
          redirect: 'news',
        },
      ],
    },
    {
      path: '/about',
      component: About,
    },
    {
      path: '*',
      redirect: '/home',
    },
  ],
})

export default router
